package com.swak.reactivex.threads.waitstrategy;

import java.util.concurrent.TimeoutException;

import com.swak.reactivex.threads.Barrier;
import com.swak.reactivex.threads.WaitStrategy;

/**
 * CPU 使用率 很高 15%; (忙等，全负荷的跑)
 * 
 * @author 618lf
 */
public class BusySpinWaitStrategy implements WaitStrategy {

	@Override
	public void waitFor(Barrier barrier) throws InterruptedException, TimeoutException {
		while (!this.checkBarrier(barrier)) {
			Thread.onSpinWait();
		}
	}

	@Override
	public void wakeup() {

	}
}
